# !/usr/bin/env python
# -*- encoding: utf-8 -*-
import datetime


class TimeWindow(object):
    """

    """
    start_time = None
    end_time = None

    def __init__(self, p_start_time=None, p_end_time=None):
        self.start_time = p_start_time
        self.end_time = p_end_time
        pass

    def is_valid(self) -> (bool):
        """

        :return:
        """
        is_valid_data = self.start_time is not None and self.end_time is not None

        time_1_struct = datetime.datetime.strptime(str(self.start_time), '%Y%m%d%H%M%S')
        time_2_struct = datetime.datetime.strptime(str(self.end_time), '%Y%m%d%H%M%S')
        gap = (time_2_struct - time_1_struct).seconds

        return is_valid_data and gap > 0

    def serialize(self) -> (dict):
        return self.__dict__
